package com.xpc.controller.qin;

import com.baomidou.mybatisplus.extension.api.R;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Qinkuer
 * @version 1.0.0
 * @ProjectName UniversityGradeAdministrationSystem
 * @ClassName TestController.java
 * @Description TODO 为了测试而测试的类
 * @createTime 2022年06月15日 03:50:00
 */
@RestController
@RequestMapping("testRoles")
public class TestController {

//    @RequiresRoles(value={"admin","user"},logical = Logical.OR)
//    @RequiresPermissions(value={"add","update"},logical = Logical.AND)


    @GetMapping("needRoleStudent")
    public R needRoleStudent(){
        Subject subject = SecurityUtils.getSubject();

        if(subject.hasRole("student")){
            return R.ok("student");
        }
        return R.failed("failed");
    }

    @GetMapping("needRoleAdmin")
    public R needRoleAdmin(){
        Subject subject = SecurityUtils.getSubject();
        if(subject.hasRole("admin")){
            return R.ok("admin");
        }
        return R.failed("failed");
    }
}
